﻿using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration.Json;

namespace XieCan.Core.Config
{
  public class AppSettingsHelper
  {
    private static IConfiguration Configuration { get; set; }

    static AppSettingsHelper()
    {
      Configuration = new ConfigurationBuilder()
                .SetBasePath(System.IO.Directory.GetCurrentDirectory())
                .AddJsonFile("appsettings.json", true, reloadOnChange: true)
                .AddJsonFile("appsettings.Development.json", true, reloadOnChange: true)
                .Build();
    }

    public static string GetValue(params string[] args)
    {
      if (args.Length == 0) {
        return "";
      }
      return Configuration[string.Join(":", args)];
    }

    ///// <summary>
    ///// 读取实体信息
    ///// </summary>
    ///// <typeparam name="T"></typeparam>
    ///// <param name="session"></param>
    ///// <returns></returns>
    //public static List<T> Get<T>(params string[] session)
    //{
    //  List<T> list = new List<T>();
    //  Configuration.Bind(string.Join(":", session), list);
    //  return list;
    //}
  }
}
